import request from '../../utils/request'


/**
 * 获取境外贸易商信息列表
 * @param cstId
 * @param page
 * @returns {Promise.<void>}
 */
export async function getBuyerList({buyerNo, name, status, beginTime, endTime, manager, waiter, ready, page}) {
    return request(apiPath.zbtie + "/api/buyer", {
        method: 'get',
        data: {buyerNo, name, status, beginTime, endTime, manager, waiter, ready, page: page.page, size: page.size}
    });
}


/**
 * 增加境外贸易商
 * @param params
 * @returns {Promise.<void>}
 */
export async function addBuyer(data) {
    return request(apiPath.zbtie + "/api/buyer", {
        method: 'post',
        data
    });
}


/**
 * 更新境外贸易商
 * @param params
 * @returns {Promise.<void>}
 */
export async function updateBuyer(data) {
    return request(apiPath.zbtie + "/api/buyer", {
        method: 'put',
        data
    });
}

/**
 * 根据id查境外贸易商
 * @param id
 * @returns {Promise.<void>}
 */
export async function getBuyerById({id}) {
    return request(apiPath.zbtie + "/api/buyer/"+ id, {
        method: 'get'
    });
}



/**
 * 删除境外贸易商
 * @param id
 * @returns {Promise.<void>}
 */
export async function deleteBuyerById({id}) {
    return request(apiPath.zbtie + "/api/buyer/"+ id, {
        method: 'delete'
    });
}

/**
 * 	外商审批记录
 * @param buyerNo
 * @param name
 * @param status
 * @param beginTime
 * @param endTime
 * @param manager
 * @param waiter
 * @param page
 * @return
 */
export async function queryBuyerApprovalList({buyerNo, name, status, beginTime, endTime, manager, waiter, page}) {
    return request(apiPath.zbtie + "/api/approval/buyer", {
        method: 'get',
        data: {buyerNo, name, status, beginTime, endTime, manager, waiter, page: page.page, size: page.size}
    });
}

/**
 * 审核境外贸易商
 * @param approvalId
 * @param status
 * @param memo
 * @return
 */
export async function approvalBuyer(data) {
    return request(apiPath.zbtie + "/api/approval/buyer", {
        method: 'put',
        data
    });
}